<template>
  <view class="recommended" style="width: 100%">
    <u-tabs
      :list="list"
      :is-scroll="false"
      :active-color="settings.theme"
      :current="current"
      @change="change"
    ></u-tabs>
    <view class="recommendedBox" v-for="i in ListAll" :key="i">
      <view class="recommendedBoxFlex">
        <view>
          <img
            class="qzz"
            v-if="i.talentPoolDO.gender"
            :src="i.talentPoolDO.gender === 1 ? nan : nv"
            alt
          />
          <text class="recommendedBoxName">{{
            i.talentPoolDO.name || "人员已删除"
          }}</text>
        </view>
        <view class="recommendedBoxTime">
          {{ formatDateAll(i.gmtModified) }}
        </view>
      </view>
      <view class="recommendedBoxTitle">
        <view class="recommendedBoxTitle1">{{
          i.recruitInfoVO.postName || "岗位已删除"
        }}</view>
        <view
          class="recommendedBoxTitle2 recommendedBoxTitle3"
          v-if="i.status === 5 || i.status === 6 || i.status === 7"
          >{{ i.status | statusFil }}</view
        >
        <view class="recommendedBoxTitle2" v-else>
          {{ i.status | statusFil }}
        </view>
      </view>
      <view
        class="recommendedBoxMoney margintop12"
        v-if="i.recruitInfoVO.lowestSalary"
      >
        <span
          v-if="i.recruitInfoVO.lowestSalary === i.recruitInfoVO.highestSalary"
          >{{ i.recruitInfoVO.highestSalary }}元</span
        >
        <span v-else
          >{{ i.recruitInfoVO.lowestSalary }}-{{
            i.recruitInfoVO.highestSalary
          }}元</span
        >
        <text>/{{ salaryGrantTypeArr[i.recruitInfoVO.salaryGrantType] }}</text>
      </view>
      <view class="recommendedBoxAddress margintop9">
        <view v-if="i.recruitInfoVO">
          <text>{{ i.recruitInfoVO.companyUnitName }}</text>
          <text
            class="marignleft8"
            :key="z"
            v-for="z in i.recruitInfoVO.cityName.split(',').splice(1)"
            >{{ z }}</text
          >
        </view>
        <view>
          <img class="shang" src="../../static/shang.png" alt />
          <text class="shangNum">{{ i.empMoneyReward || "0" }}</text>
        </view>
      </view>
    </view>
    <view v-if="ListAll.length === 0" class="meiyouBox">
      <view class="meiyou">
        <img
          style="width: 200px; height: 200px"
          src="../../static/meiyou.png"
          alt
        />
        <view>暂时还没有记录</view>
      </view>
    </view>
  </view>
</template>

<script>
import { selectByPrincipal } from "./api";
import { formatDateAll } from "@/utils/tools";
import { mapState } from 'vuex'
export default {
  data() {
    return {
      salaryGrantTypeArr: ["小时", "日", "月", "年"],
      ListAll: [],
      nan: require("../../static/nan1.png"),
      nv: require("../../static/nv1.png"),
      list: [
        {
          name: "处理中",
        },
        {
          name: "已通过",
        },
        {
          name: "未通过",
        },
      ],
      current: 0,
    };
  },
  filters: {
    statusFil(val) {
      if (val === 1) {
        return "已投递";
      } else if (val === 2) {
        return "已约面";
      } else if (val === 3) {
        return "待入职";
      } else if (val === 4) {
        return "已招聘";
      } else if (val === 5) {
        return "简历不合适";
      } else if (val === 6) {
        return "面试已拒绝";
      } else if (val === 7) {
        return "面试不合适";
      } else if (val === 8) {
        return "放弃入职";
      } else {
        return "";
      }
    },
  },
  computed: {
    ...mapState(['settings'])
  },
  onShow() {
    this.change(0);
  },
  methods: {
    formatDateAll,
    change(index) {
      console.log(index);
      this.current = index;
      const data = {
        sourceId: this.$store.state.user.empId,
        sourceType: "emp",
      };
      selectByPrincipal(data)
        .then((res) => {
          console.log(res);
          this.ListAll =
            index === 0
              ? res.processingList
              : index === 1
              ? res.passedList
              : res.notPassList;
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
};
</script>

<style lang="scss">
@import "../../../styles/styles.scss";
@import "./index.scss";
</style>
